home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / mesa / mesa-glut / src-glut.aos / glutxfunc.c < prev    next >
C/C++ Source or Header  |  2000-02-23  |  4KB  |  176 lines

  1. /*
  2.  * Amiga GLUT graphics library toolkit
  3.  * Version:  1.1
  4.  * Copyright (C) 1998 Jarno van der Linden
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Library General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Library General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Library General Public
  17.  * License along with this library; if not, write to the Free
  18.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. /*
  22.  * glutXFunc.c
  23.  *
  24.  * Version 1.0  27 Jun 1998
  25.  * by Jarno van der Linden
  26.  * jarno@kcbbs.gen.nz
  27.  *
  28.  */
  29.  
  30. #include <stdlib.h>
  31. #include <inline/intuition.h>
  32. #include "glutstuff.h"
  33.  
  34. void glutTimerFunc(unsigned int msecs, void (*func) (int value), int value)
  35. {
  36.   if (glutstuff.curwin) {
  37.     struct GlutTimer *gt;
  38.  
  39.     if ((gt = AllocVecPooled(glutPool, sizeof(struct GlutTimer)))) {
  40.       gt->timerfunc = func;
  41.       gt->TimerValue = value;
  42.  
  43.       CurrentTime(>->secs, >->micros);
  44.       gt->micros += msecs * 1000;
  45.       while(gt->micros >= 1000000) {
  46.         gt->micros -= 1000000;
  47.         gt->secs += 1;
  48.       }
  49.       
  50.       DEBUGOUT(4, "add timer for (%ld:%ld) (+%d)\n", gt->secs, gt->micros, msecs);
  51.       dAddTail(&glutstuff.curwin->WindowTimers, >->TimerNode);
  52.     }
  53.   }
  54.   else
  55.     DEBUGOUT(1, "no window to time to\n");
  56. }
  57.  
  58. void glutDisplayFunc(void (*func) (void))
  59. {
  60.   glutstuff.curwin->displayfunc = func;
  61. }
  62.  
  63. void glutIdleFunc(void (*func) (void))
  64. {
  65.   glutstuff.idlefunc = func;
  66. }
  67.  
  68. void glutEntryFunc(void (*func) (int state))
  69. {
  70.   if (glutstuff.curwin)
  71.     glutstuff.curwin->entryfunc = func;
  72. }
  73.  
  74. void glutKeyboardFunc(void (*func) (unsigned char key, int x, int y))
  75. {
  76.   if (glutstuff.curwin)
  77.     glutstuff.curwin->keyboardfunc = func;
  78. }
  79.  
  80. void glutKeyboardUpFunc(void (*func) (unsigned char key, int x, int y))
  81. {
  82.   if (glutstuff.curwin)
  83.     glutstuff.curwin->keyboardupfunc = func;
  84. }
  85.  
  86. void glutReshapeFunc(void (*func) (int width, int height))
  87. {
  88.   if (glutstuff.curwin)
  89.     glutstuff.curwin->reshapefunc = func;
  90. }
  91.  
  92. void glutVisibilityFunc(void (*func) (int state))
  93. {
  94.   if (glutstuff.curwin)
  95.     glutstuff.curwin->visibilityfunc = func;
  96. }
  97.  
  98. void glutSpecialFunc(void (*func) (int key, int x, int y))
  99. {
  100.   if (glutstuff.curwin)
  101.     glutstuff.curwin->specialfunc = func;
  102. }
  103.  
  104. void glutSpecialUpFunc(void (*func) (int key, int x, int y))
  105. {
  106.   if (glutstuff.curwin)
  107.     glutstuff.curwin->specialupfunc = func;
  108. }
  109.  
  110. void glutWindowStatusFunc(void (*func) (int status))
  111. {
  112.   if (glutstuff.curwin)
  113.     glutstuff.curwin->windowstatusfunc = func;
  114. }
  115.  
  116. void glutMenuStatusFunc(void (*func) (int status, int x, int y))
  117. {
  118.   glutstuff.menustatusfunc = func;
  119. }
  120.  
  121. void glutMenuStateFunc(void (*func) (int state))
  122. {
  123.   glutstuff.menustatefunc = func;
  124. }
  125.  
  126. void glutMouseFunc(void (*func) (int buton, int state, int x, int y))
  127. {
  128.   if (glutstuff.curwin)
  129.     glutstuff.curwin->mousefunc = func;
  130. }
  131.  
  132. void glutJoystickFunc(void (*func) (unsigned int buttonMask, int x, int y, int z), int pollInterval)
  133. {
  134.   if (glutstuff.curwin) {
  135.     glutstuff.curwin->joystickfunc = func;
  136.     glutstuff.curwin->joystickpoll = pollInterval;
  137.   }
  138. }
  139.  
  140. void glutForceJoystickFunc(void)
  141. {
  142. }
  143.  
  144. void glutMotionFunc(void (*func) (int x, int y))
  145. {
  146.   if (glutstuff.curwin)
  147.     glutstuff.curwin->motionfunc = func;
  148. }
  149.  
  150. void glutPassiveMotionFunc(void (*func) (int x, int y))
  151. {
  152.   if (glutstuff.curwin)
  153.     glutstuff.curwin->passivemotionfunc = func;
  154. }
  155.  
  156. void glutSpaceballMotionFunc(void (* func)(int x, int y, int z)) {
  157. }
  158.  
  159. void glutSpaceballRotateFunc(void (* func)(int x, int y, int z)) {
  160. }
  161.  
  162. void glutSpaceballButtonFunc(void (* func)(int button, int state)) {
  163. }
  164.  
  165. void glutButtonBoxFunc(void (* func)(int button, int state)) {
  166. }
  167.  
  168. void glutDialsFunc(void (* func)(int dial, int value)) {
  169. }
  170.  
  171. void glutTabletMotionFunc(void (* func)(int x, int y)) {
  172. }
  173.  
  174. void glutTabletButtonFunc(void (* func)(int button, int state, int x, int y)) {
  175.